package com.rykj.widget

import android.content.Context
import android.graphics.drawable.ColorDrawable
import android.view.Gravity
import android.view.LayoutInflater
import android.view.View
import android.widget.LinearLayout
import android.widget.TextView
import com.rykj.R
import com.rykj.ext.clickWithTrigger

/**
 * @author hdl
 * @description 选择地图
 * @date 2019/7/25
 */
class SelectMapPopWindow(context: Context) : BasePopupWindow() {

    init {
        mContext = context
        width = LinearLayout.LayoutParams.MATCH_PARENT
        height = LinearLayout.LayoutParams.WRAP_CONTENT
        val view = LayoutInflater.from(context).inflate(R.layout.popwindow_select_map, null)
        isFocusable = true
        setBackgroundDrawable(ColorDrawable(0x00))
        val tv1 = view.findViewById<TextView>(R.id.tv_1)
        val tv2 = view.findViewById<TextView>(R.id.tv_2)
        //        val tv3 = view.findViewById<TextView>(R.id.tv_3)
        tv1?.clickWithTrigger { block.invoke(1) }
        tv2?.clickWithTrigger { block.invoke(2) }
        //        tv3?.clickWithTrigger { block.invoke(3) }
        contentView = view
        setOnDismissListener(this)
    }

    var block = fun(_: Int) {}

    override fun show(parent: View) {
        super.show(parent)
        showAtLocation(parent, Gravity.BOTTOM, 0, 0)
    }

}
